// 括号生成
var dfs = function (result, n, left, right, temp) {
  if (temp.length === n * 2) {
    result.push(temp)
  } else {
    if (left < n) {
      dfs(result, n, left + 1, right, temp + '(')
    }
    if (right < left) {
      dfs(result, n, left, right + 1, temp + ')')
    }
  }
}
var generateParenthesis = function (n) {
  let result = []
  dfs(result, n, 0, 0, '')
  return result
}
